package com.baige.api.app.controller;

import com.baige.api.app.sdk.request.BrandNameResponse;
import com.baige.api.app.sdk.request.GoodsListRequest;
import com.baige.api.app.sdk.response.GoodsBrandDetailResponse;
import com.baige.api.app.sdk.response.GoodsConditionResponse;
import com.baige.api.app.sdk.response.GoodsDetailResponse;
import com.baige.api.app.sdk.response.GoodsResponse;
import com.baige.common.core.BaseResponse;
import com.baige.common.core.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 商品接口
 * @author wulg
 * @date 2018/12/13.
 */
@Api(value = "GoodsController", description = "商品接口", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/api/rest/goods")
public class GoodsController
{
    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);

    /**
     * 商品列表
     *
     * @param requestParams 请求参数
     * @param bindingResult 参数校验
     * @return Result<List<GoodsResponse>>
     */
    @PostMapping(value = "/v1", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "商品列表", notes = "商品列表", httpMethod = "POST", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<List<GoodsResponse>> getGoodsListByParams(@Valid @RequestBody GoodsListRequest requestParams, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            logger.error("商品列表参数传递错误,message:{}", bindingResult.getFieldErrors().get(0).getDefaultMessage());
            return BaseResponse.newErrorParamReturnObject(bindingResult.getFieldErrors().get(0).getDefaultMessage());
        }
        return null;
    }


    /**
     * 商品详情
     *
     * @param goodsId 商品id
     * @return Result<GoodsDetailResponse>
     */
    @GetMapping(value = "/v1/{goodsId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "商品详情", notes = "商品详情", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<GoodsDetailResponse> getGoodsDetailById(@PathVariable("goodsId") String goodsId) {
        return null;
    }


    /**
     * 用户同类别商品推荐列表
     *
     * @param goodsId 商品id
     * @return Result<List<GoodsResponse>>
     */
    @GetMapping(value = "/v1/sameCategoryRec/{goodsId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "用户同类别商品推荐列表", notes = "用户同类别商品推荐列表", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<List<GoodsResponse>> getSameCategoryRecGoodsList(@PathVariable("goodsId") String goodsId) {
        return null;
    }

    /**
     * 主编推荐列表
     *
     * @return Result<List<GoodsResponse>>
     */
    @GetMapping(value = "/v1/recommend", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "主编推荐列表", notes = "主编推荐列表", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<List<GoodsResponse>> getRecommendGoodsList() {
        return null;
    }

    /**
     * 商品筛选条件列表
     * @return Result<List<GoodsConditionResponse>>
     */
    @GetMapping(value = "/v1/conditions", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "商品筛选条件列表", notes = "商品筛选条件列表", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<List<GoodsConditionResponse>> getGoodsConditionList() {
        return null;
    }


    /**
     * 商品品牌信息
     *
     * @param brandId 品牌id
     * @return Result<GoodsBrandDetailResponse>
     */
    @GetMapping(value = "/v1/brand/{brandId}", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "商品品牌信息", notes = "商品品牌信息", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<GoodsBrandDetailResponse> getGoodsBrandDetailById(@PathVariable("brandId") String brandId) {
        return null;
    }


    /**
     * 全部品牌列表
     * @return Result<List<BrandNameResponse>>
     */
    @GetMapping(value = "/v1/brand", produces = {"application/json;charset=UTF-8", "application/xml;charset=UTF-8"})
    @ApiOperation(value = "全部品牌列表", notes = "全部品牌列表", httpMethod = "GET", produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
    public Result<List<BrandNameResponse>> getAllGoodsBrandList() {
        return null;
    }

}
